package com.jml.mayi.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumer {

	/**
	 * 消费者使用日志打印消息
	 */
	@KafkaListener(topics = "my_test")
	public void receive(ConsumerRecord<?, ?> consumer) throws Exception {
		System.out.println("topic名称:" + consumer.topic() + ",key:" + consumer.key() +"data:" + consumer.value() + ",分区位置:" + consumer.partition()
				+ ", 下标" + consumer.offset());
	}

}
